package Client;

import javax.swing.*;
import java.awt.*;

public class SignUpUI extends JFrame {

    static JTextField tUid;
    static JPasswordField tPassword;

    JButton bSignUp, bCancel, bCheckUid;

    private JLabel lUid, lPassword;
    private Font font1;

    public SignUpUI() {
        setTitle("用户注册界面");
        setSize(437, 340);
        setLocationRelativeTo(null);
        SignUpUISet();//调用组件布局方法
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);//只关闭本界面，不影响主程序
        setResizable(false);//设置窗口大小不可以改变

        setSignUpActionListener(new SignUpActionListener(this));

        setVisible(true);
    }

    private void SignUpUISet() {//组件布局方法

        setLayout(null);

        font1 = new Font("楷体", Font.BOLD, 20);

        lUid = new JLabel("账号:");
        lUid.setBounds(85, 70, 60, 50);
        lUid.setFont(font1);

        tUid = new JTextField("");
        tUid.setBounds(145, 80, 150, 30);
        tUid.setFont(font1);
        tUid.setEditable(true);

        lPassword = new JLabel("密码：");
        lPassword.setBounds(85, 130, 60, 50);
        lPassword.setFont(font1);

        tPassword = new JPasswordField("");
        tPassword.setBounds(145, 140, 150, 30);
        tPassword.setFont(font1);
        tPassword.setEditable(true);

        bSignUp = new JButton("注册");
        bSignUp.setBounds(130, 190, 70, 30);
        getRootPane().setDefaultButton(bSignUp);

        bCancel = new JButton("取消");
        bCancel.setBounds(210, 190, 70, 30);

        this.add(lUid);
        this.add(tUid);
        this.add(lPassword);
        this.add(tPassword);
        this.add(bSignUp);
        this.add(bCancel);


    }

    private void setSignUpActionListener(SignUpActionListener sa) {
        bSignUp.addActionListener(sa);
        bCancel.addActionListener(sa);
    }
}

